import java.util.*;
public class Main {

    public static void main(String[] args) {
        Map<Character,Character> map = new HashMap<Character,Character>();
        map.put('A','2');
        map.put('B','2');
        map.put('C','2');
        map.put('D','3');
        map.put('E','3');
        map.put('F','3');
        map.put('G','4');
        map.put('H','4');
        map.put('I','4');
        map.put('J','5');
        map.put('K','5');
        map.put('L','5');
        map.put('M','6');
        map.put('N','6');
        map.put('O','6');
        map.put('P','7');
        map.put('Q','7');
        map.put('R','7');
        map.put('S','7');
        map.put('T','8');
        map.put('U','8');
        map.put('V','8');
        map.put('W','9');
        map.put('X','9');
        map.put('Y','9');
        map.put('Z','9');
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int numbers = in.nextInt();
            in.nextLine();
            Set<String> set = new TreeSet<String>();
            for(int i = 0; i < numbers; i++){
                String number = in.nextLine();
                StringBuilder stringBuilder = new StringBuilder();
                for(int j = 0; j < number.length(); j++){
                    char c = number.charAt(j);
                    if (c == '-') continue;
                    if(c <= '9' && c >= '0'){
                        stringBuilder.append(c);
                    }else {
                        stringBuilder.append(map.get(c));
                    }
                }
                stringBuilder.insert(3,'-');
                set.add(stringBuilder.toString());
            }

            for(String s : set){
                System.out.println(s);
            }
        }
    }
/*
12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279
 */


    static boolean flag;
    static List<List<int[]>> paths;
    static List<int[]> list;

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            flag = false;
            paths = new ArrayList<List<int[]>>();
            list = new ArrayList<int[]>();
            char[][] boards = new char[10][10];
            boolean[][] maze = new boolean[10][10];
            maze[0][1] = true;
            for(int i = 0; i < 10; i++){
                String row = in.nextLine();
                for(int j = 0; j < 10; j++){
                    boards[i][j] = row.charAt(j);
                }
            }// 初始化迷宫
//             找路径
            list.add(new int[]{0,1});
            getPath(boards, 0, 1, maze);
            int minPath = Integer.MAX_VALUE;
            for(int i = 0; i < paths.size(); i++){
                minPath = Math.min(paths.get(i).size(), minPath);
            }
            System.out.println(minPath-1);
        }
    }
    //                     目前的位置
    public static void getPath(char[][] boards, int row, int line, boolean[][] maze){
        if (row == 9 && line == 8){
            paths.add(new ArrayList(list));
            if (list.size() == 17){
                flag = true;
            }
        }
        if (row >= 10 || line >= 10 || flag){
            return;
        }

        // 右
        if(line < 9 && boards[row][line+1] == '.' && !maze[row][line+1]){
            list.add(new int[]{row, line + 1});
            maze[row][line+1] = true;
            getPath(boards, row, line + 1, maze);
            list.remove(list.size() - 1);
            maze[row][line+1] = false;
        }
        // 下
        if(row < 9 && boards[row+1][line] == '.' && !maze[row+1][line]){
            list.add(new int[]{row+1,line});
            maze[row+1][line] = true;
            getPath(boards,row+1,line, maze);
            list.remove(list.size()-1);
            maze[row+1][line] = false;
        }

        // 左
        if(line > 0 && boards[row][line-1] == '.' && !maze[row][line-1]){
            list.add(new int[]{row, line - 1});
            maze[row][line-1] = true;
            getPath(boards, row, line - 1, maze);
            list.remove(list.size() - 1);
            maze[row][line-1] = false;
        }
        // 上
        if(row > 0 && boards[row-1][line] == '.' && !maze[row-1][line]){
            list.add(new int[]{row - 1, line});
            maze[row-1][line] = true;
            getPath(boards, row - 1, line, maze);
            list.remove(list.size() - 1);
            maze[row-1][line] = false;
        }

    }
}
/*
#.########
#......#.#
#......#.#
#.....##.#
#......#.#
#......#.#
#......#.#
#......#.#
#........#
########.#
*/